package com.example.sec_demo.controller;



import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;



@RestController
@RequestMapping("user")
public class UserController {
//    @Resource
//    IUserService iUserService;

    @GetMapping
    public Object getUser(){
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        return authentication.getPrincipal();
    }


//    public void getUser1(Principal principal){
//        String name = principal.getName();
//        Users user=iUserService.query(name);
//
//    }
}
